主题
列出已加载模型 - YoloListModels
函数简介
返回当前实例已加载的全部模型信息(JSON 数组)。
接口名称
YoloListModelsDLL 调用
long YoloListModels(long ola);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug 对象指针,由 CreateCOLAPlugInterFace 生成。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
// 列出当前已加载的模型
auto models = ola.YoloListModels();
// 遍历 models 查看 ModelHandle、TaskType 等csharp
using OLAPlug;
var ola = new OLAPlugServer();
// 列出当前已加载的模型
var models = ola.YoloListModels();
// 遍历 models 查看 ModelHandle、TaskType 等python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
# 列出当前已加载的模型
models = ola.YoloListModels()
# 遍历 models 查看 ModelHandle、TaskType 等java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
// 列出当前已加载的模型
var models = ola.YoloListModels();
// 遍历 models 查看 ModelHandle、TaskType 等cpp
var ola = com("OlaPlug.OlaSoft")
// 列出当前已加载的模型
var models = ola.YoloListModels()
// 遍历 models 查看 ModelHandle、TaskType 等vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
' 列出当前已加载的模型
models = ola.YoloListModels()
' 遍历 models 查看 ModelHandle、TaskType 等text
.局部变量 ola, OLAPlug
ola.创建 ()
' 列出当前已加载的模型
models = ola.YoloListModels()
' 遍历 models 查看 ModelHandle、TaskType 等aardio
import OLAPlugServer;
var ola = OLAPlugServer();
// 列出当前已加载的模型
var models = ola.YoloListModels();
// 遍历 models 查看 ModelHandle、TaskType 等text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
// 列出当前已加载的模型
自动 models = ola.YoloListModels()
// 遍历 models 查看 ModelHandle、TaskType 等cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
// 列出当前已加载的模型
auto models = ola.YoloListModels();
// 遍历 models 查看 ModelHandle、TaskType 等原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
long modelsJsonPtr = YoloListModels(instance);
if (modelsJsonPtr != 0) {
char modelsJson[512] = {0};
GetStringFromPtr(modelsJsonPtr, modelsJson, sizeof(modelsJson));
FreeStringPtr(modelsJsonPtr);
}csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringFromPtr(long ptr, StringBuilder lpString, int size);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FreeStringPtr(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringSize(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
long instance = CreateCOLAPlugInterFace();
long modelsJsonPtr = YoloListModels(instance);
if (modelsJsonPtr != 0) {
StringBuilder modelsJson = new StringBuilder(GetStringSize(modelsJsonPtr) + 1);
GetStringFromPtr(modelsJsonPtr, modelsJson, modelsJson.Capacity);
FreeStringPtr(modelsJsonPtr);
string modelsJsonStr = modelsJson.ToString();
}python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
modelsJsonPtr = YoloListModels(instance)
if modelsJsonPtr:
buf = create_string_buffer(512)
ola.GetStringFromPtr(modelsJsonPtr, buf, 512)
ola.FreeStringPtr(modelsJsonPtr)
modelsJson = buf.value.decode("utf-8")返回值
长整数型:JSON 字符串指针;数组元素字段同 YoloGetModelInfo。
注意事项
- 需要插件已开通 YOLO 模块权限(Reg、Login的FeatureList中包含YOLO特性)。
- 模型元数据见 ModelInfo与ModelConfig说明。
- 返回的 JSON 字符串须调用 FreeStringPtr 释放。
